<%--
  Created by IntelliJ IDEA.
  User: lilingrui
  Date: 2021/5/11
  Time: 13:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<html>
<head>
    <title>Title</title>
        <link rel="stylesheet" href="/boot/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
        <link rel="stylesheet" href="/boot/css/chat.css">
        <link rel="stylesheet" href="/boot/css/chatS.css">



    <link rel="stylesheet" href="/boot/cssgd/roll.css">

    <script src="/boot/jsgd/jquery.min.js"  type="text/javascript"></script>
    <script src="/boot/jsgd/scrollbar.js" type="text/javascript"></script>

</head>
<body bgcolor="#fef4d9" onload="scrollit()">
<div id="glowdiv" style="position:absolute;visibility:visible;width:600px;text-align:center; top:185px;left:70px;font-family:隶书;font-size:30pt;color:000000"></div>

        <!-- 表单开始 -->
                        <%--                    聊天框--%>
                       <div><span id="uname" value="${uname}"></span></div>

                        <div class="wrapper" style="width: 100%;height:  100%;left: 38%;margin-top: 0px">
                            <div class="container">
                                <div class="left">
                                    <div class="top">
                                        <input type="text" placeholder="Search" />
                                        <a href="javascript:;" class="search"></a>
                                    </div>
                                                <ul class="people" onclick="serrchText1()">
                                                    <li class="person" >
<%--                                                        <span>${User.uname}</span>--%>
                                                        <span class="name">二手车售后群聊</span>
                                                        <span class="time">2020-2</span>
                                                        <span class="preview"  id="1">1</span>
                                                    </li>
                                                </ul>
                                    <ul class="people" onclick="serrchText2()">
                                        <li class="person" >
<%--                                            <span>${User.uname}</span>--%>
<%--                                           <img src="/boot/img/chat/dog.png" alt="" />  &lt;%&ndash; ${accs.accompanyImg}&ndash;%&gt;--%>
                                            <span class="name">保险群聊</span>
                                            <span class="time">2020-2</span>
                                            <span class="preview"  id="2">2</span>
                                        </li>
                                    </ul>

                                </div>


                                <div class="right" >
<%--////////--%>

                                    <div class="top"><span>To: <c:if test="${chats.get(0).chatType == 1}"><span class="name">售后群聊</span></c:if>
                                    <c:if test="${chats.get(0).chatType == 2}"><span class="name">保险群聊</span></c:if>
                                    </span></div>

                                    <div class="chataaa" style="margin-left: 10px"><div class="conversation-start">
                                        <span><fmt:formatDate value="${time}" pattern="yyyy-MM-d"/></span>
                                    </div>
<%--                                           ///数据消息--%>

                                        <div class="scroll_main">
                                            <div class="scroll_wrap">




                                                <div class="scroll_cont">
                                     <c:forEach items="${chats}" var="c">
                                         <c:if test="${c.chatPerson != user.uname }">
<%--                                        <img src="/boot/img/${user.uphoto }" alt="" style="width: 10%;height: 10%;left: 0px;position: absolute" />--%>
<%--                                             <span style="width: 10%;height: 10%;left: 0px;position: absolute" >${c.chatPerson}:</span>--%>
                                             <div class="bubble you" style="left: 3%">
                                                     ${c.chatPerson}: ${c.chatText }
                                                </div>
                                         </c:if>


                                         <c:if test="${c.chatPerson == user.uname }">
                                                <div class="bubble me" >

                                                        ${c.chatText }
                                                </div>
                                         </c:if>
                                     </c:forEach>
                                                </div>






                                                <div class="scroll_bar" id="scroll_slider">
                                                    <div class="scroll_slider"></div>
                                                </div>
                                            </div>
                                        </div>





<%--///////////////--%>
                                        <div class="write" style="right: 0px">
                                            <input type="text" id="AccTextaa" />
                                            <a href="javascript:;" class="write-link send"></a>
<%--                                            <button  class="layui-btn layui-btn-radius layui-btn-normal" id="fat-btn" class="btn btn-primary" data-loading-text="发送"--%>
<%--                                                    type="button" onclick="sendText(${user.uId},${chats.get(0).chatType})">发送--%>
<%--                                            </button>--%>
                                            <button onclick="sendText('${uname}',${chats.get(0).chatType})">发送</button>
                                        </div>
                                    </div>



                                </div>














                            </div>
                        </div>





        </div>
<script>

    new CusScrollBar({
        contentSelector: '.scroll_cont', //滚动内容区
        barSelector: '.scroll_bar', //滚动条
        sliderSelector: '.scroll_slider' //滚动滑块
    });

    function scrollit(){
        for (I=1; I<=500; I++){
            parent.scroll(1,I)
        }
    }


    function sendText(){
        window.location="/boot/chat/getText";
    }

    function serrchText1(){
        let textType=1;
        window.location="/boot/chat/searchText?text_type="+textType;
    }
    function serrchText2(){
        let textType=2;
        window.location="/boot/chat/searchText?text_type="+textType;
    }
    function sendText(uname,chatType){


        var now = new Date();
        var div = document.getElementById('scroll_slider');
        div.innerHTML = div.innerHTML + 'time_' + now.getTime() + '<br />';
        div.scrollTop = div.scrollHeight;



     let chatText=$("#AccTextaa").val();

     console.log(uname);

        window.location="/boot/chat/sendText?chatType="+chatType+"&uname="+uname+"&chatText="+chatText;
    }
</script>

        <script src="/boot/plugins1/jquery/jquery.min.js"></script>
</body>
</html>
